/*
 * @Author: xuesong
 * @Date: 2021-12-01 17:37:53
 * @LastEditors: xuesong
 * @LastEditTime: 2022-01-12 20:10:17
 * @FilePath: \BLE-SDK-SVN499-V02\projects\ble_peripheral\uart_ble\src\Remote\AdcMeasure.h
 */



#ifndef __ADC_MEASURE_H__
#define __ADC_MEASURE_H__

#include "types.h"
#include "adc.h"

#ifdef __cplusplus
extern "C"
{
#endif
//----------------------------------------------------
#define D_BAT_VLO 	33  // 3.3V
#define D_BAT_FULL 	38 // 4.2V
#define D_BAT_Levl1 35  //3.5v
#define D_BAT_Levl2 37  //3.7v
#define D_BAT_Plevl1 ((D_BAT_Levl1-D_BAT_VLO)*100/(D_BAT_FULL-D_BAT_VLO))
#define D_BAT_Plevl2 ((D_BAT_Levl2-D_BAT_VLO)*100/(D_BAT_FULL-D_BAT_VLO))
//----------------------------------------------------


typedef struct{
	union {
        struct
        {
            unsigned char enableBatLo	: 1;    // 
            unsigned char Finish1S	    : 1;    // 
            unsigned char init 		    : 1;    // 
            unsigned char OK  	        : 1;    // 
            unsigned char LO  	        : 1;    // 
            unsigned char Chage         : 1;    // 
            unsigned char ChageFull     : 1;    // 
            unsigned char AdOK  	    : 1;    // 
            unsigned char Ad0ok         : 1;    // 
            unsigned char Ad1ok         : 1;    // 
            unsigned char Av1st         : 1;    // 
        }flagBit;
        uint16_t flagByte;
    }Flag;
    int8    BateryVoltage[2];
	uint16  BateryVolAD[2];
    int8_t  BatteryLevle;
}Battery_Str_t;
//----------------------------------------------------
extern Battery_Str_t   Battery_t; 
//----------------------------------------------------
void UserMeasureTask( AdcCfg_t tempAdcCfg );
void FunUserADC(void);
#ifdef __cplusplus
}
#endif

#endif

